# -------- 依赖阶段 --------
    FROM python:3.11-slim as base
    ENV PYTHONDONTWRITEBYTECODE=1 \
        PYTHONUNBUFFERED=1 \
        PIP_NO_CACHE_DIR=1 \
        PIP_DISABLE_PIP_VERSION_CHECK=1
    
    WORKDIR /app
    # 提前复制并安装依赖，只要 requirements.txt 没变就能用缓存
    COPY requirements.txt .
    RUN python -m venv /venv && \
        /venv/bin/pip install --upgrade pip && \
        /venv/bin/pip install -r requirements.txt
    
    # -------- 运行阶段 --------
    FROM python:3.11-slim
    WORKDIR /app
    # 把虚拟环境整体拷进来
    COPY --from=base /venv /venv
    ENV PATH="/venv/bin:$PATH"
    COPY . .
    EXPOSE 3000
    CMD [ "tail", "-f", "/etc/hosts" ]